﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
/// Summary description for TrainingCoursePresenter
/// </summary>
[Serializable()]
public class TrainingCoursePresenter
{
    private ITrainingCourseView _view;
    private TrainingCourse _SampleCourse;
    private int _CurrentSlide = -1;

	public TrainingCoursePresenter(ITrainingCourseView view)
	{
	    _view = view;
	}

    public void Initialize()
    {
        if (!_view.IsPostBack) {
            _SampleCourse = new TrainingCourse("Club Officer Training - President");
            _SampleCourse.Add(new TrainingCourseSlide("Page 1", "~/courses/content/president/images/slide1.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 2", "~/courses/content/president/images/slide2.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 3", "~/courses/content/president/images/slide3.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 4", "~/courses/content/president/images/slide4.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 5", "~/courses/content/president/images/slide5.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 6", "~/courses/content/president/images/slide6.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 7", "~/courses/content/president/images/slide7.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 8", "~/courses/content/president/images/slide8.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 9", "~/courses/content/president/images/slide9.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 10", "~/courses/content/president/images/slide10.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 10", "~/courses/content/president/images/slide11.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 10", "~/courses/content/president/images/slide12.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 10", "~/courses/content/president/images/slide13.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 10", "~/courses/content/president/images/slide14.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 10", "~/courses/content/president/images/slide15.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 10", "~/courses/content/president/images/slide16.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 10", "~/courses/content/president/images/slide17.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 10", "~/courses/content/president/images/slide18.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 10", "~/courses/content/president/images/slide19.jpg"));
            _SampleCourse.Add(new TrainingCourseSlide("Page 10", "~/courses/content/president/images/slide20.jpg"));

            _view.CourseTitle = _SampleCourse.Title;
            _view.TrainingCourse = _SampleCourse;

            FirstSlide();
        } 
        else
        {
            _SampleCourse = _view.TrainingCourse;
            _CurrentSlide = _view.CurrentSlide;
        }

    }

    public void NextSlide()
    {
        if (_CurrentSlide < _SampleCourse.Count)
        {
            _view.CurrentSlide = ++_CurrentSlide;
            _view.CurrentSlideURL = _SampleCourse[_CurrentSlide].HyperLink;
        }
        else
        {
            this.Exit();
        }
    }

    public void PreviousSlide()
    {
        if (_CurrentSlide > 0)
            _view.CurrentSlide = --_CurrentSlide;
            _view.CurrentSlideURL = _SampleCourse[_CurrentSlide].HyperLink;
    }

    public void FirstSlide()
    {
        _CurrentSlide = 0;
        _view.CurrentSlide = _CurrentSlide;
        _view.CurrentSlideURL = _SampleCourse[_CurrentSlide].HyperLink;
    }

    public void PreviousSection() {}

    public void NextSection() {}

    public void Exit()
    {
        _view.Response.Redirect("~/courses/catalog.aspx");
    }

}
